package cn.itsource.zcn.pay.mapper;

import cn.itsource.zcn.pay.domain.PayBill;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 支付单(PayBill)表数据库访问层
 *
 * @author makejava
 * @since 2021-08-26 17:56:07
 */
public interface PayBillMapper {

    /**
     * 新增数据
     *
     * @param tPayBill 实例对象
     */
    @Insert("insert into t_pay_bill" +
            "(digest,money,state,lastPayTime,payChannel,createTime,updateTime,user_id,nickName,unionPaySn,businessType,businessKey,shop_id,order_id,orderSn)" +
            "values (#{digest},#{money},#{state},#{lastPayTime},#{payChannel},#{createTime},#{updateTime},#{user_id},#{nickName},#{unionPaySn},#{businessType},#{businessKey},#{shop_id},#{order_id},#{orderSn})")
    void save(PayBill tPayBill);

    /**
     * 修改数据
     *
     * @param tPayBill 实例对象
     */
    @Update("update t_pay_bill set " +
            "digest=#{digest},money=#{money},state=#{state},lastPayTime=#{lastPayTime},payChannel=#{payChannel},createTime=#{createTime},updateTime=#{updateTime},user_id=#{user_id},nickName=#{nickName},unionPaySn=#{unionPaySn},businessType=#{businessType},businessKey=#{businessKey},shop_id=#{shop_id},order_id=#{order_id},orderSn=#{orderSn} " +
            "where id = #{id}")
    void update(PayBill tPayBill);

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     */
    @Delete("delete from t_pay_bill where id = #{id} ")
    void delete(Long id);


    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Select("select * from t_pay_bill where id = #{id}")
    PayBill queryById(Long id);


    @Select("select * from t_pay_bill where orderSn = #{orderSn}")
    PayBill queryByOrderSn(String orderSn);
    /**
     * 查询全部
     *
     * @return 对象列表
     */
    @Select("select * from t_pay_bill")
    List<PayBill> queryAll();

    /**
     * 批量新增数据（MyBatis原生foreach方法）
     *
     * @param entities List<PayBill> 实例对象列表
     */
    void insertBatch(@Param("PayBills") List<PayBill> entities);

    /**
     * 批量删除数据（MyBatis原生foreach方法）
     *
     * @param ids List<Integer> 实例对象列表
     */
    void deleteBatch(@Param("ids") List<Integer> ids);


}

